//安全设置显示页面 0
//修改手机 1
//修改登录密码 2
//修改支付密码 3


//(function(){
define(function(require,exports,module){
	"require:nomunge,exports:nomunge,module:nomunge";
	//异步请求
	var wind_async=require('ddf_wind_async');
		
	var base=require('component-base');
		
	var history=require('component-history');
	
	require('component-page');

/**
 * 打开安全信息页面
 */
//function openSafeSetPage(){
exports.init = function(m){
	history.addHis(this,arguments);//增加历史
    window.$ddf_safeSet = m;
	var htmlStr="";
	htmlStr += '<div id="content-header">';
	htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href="#" class="current">安全设置</a></div>';
	htmlStr += '</div> ';
	htmlStr += '<div class="container-fluid">';
	htmlStr += '<div class="row-fluid">';
	htmlStr += '<div class="span12">';
	
	htmlStr += '<div id="alert-tips0" ></div>';
	
	
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title">';
	htmlStr += '<span class="icon">';
	htmlStr += '<i class="icon-pencil"></i>';
	htmlStr += '</span>';
	htmlStr += '<h5>操作</h5>';
	htmlStr += '</div>      ';
	htmlStr += '<div class="widget-content">';
	htmlStr += '<button class="btn btn-warning" type="button" onClick=$ddf_safeSet.editMobile()>更换绑定手机号码</button> ';
	htmlStr += '<button class="btn btn-success" type="button" onClick=$ddf_safeSet.editLoginPassword()>修改登录密码</button> ';
	htmlStr += '<button class="btn btn-primary" type="button" style="display:none" id="accountUp" onClick=$ddf_safeSet.editPayPassword()>修改支付密码</button>  ';
	htmlStr += '<button class="btn btn-primary" type="button" style="display:none" id="accountIn" onClick=$ddf_safeSet.loadinsertPayPassword()>新增支付密码</button>  ';
	htmlStr += '</div>';
	htmlStr += '</div>             ';
	
	
    
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
	htmlStr += '<h5>安全设置信息</h5>';
	htmlStr += '</div>';
	htmlStr += '<div class="widget-content nopadding">';
	htmlStr += '<form class="form-horizontal">	   ';
	htmlStr += '<div class="control-group" id="control-group-shopName">';
	htmlStr += '<label class="control-label">商户帐号：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<span class="inp_span" id="show_shopName" ></span>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-mobile">';
	htmlStr += '<label class="control-label">绑定手机：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<span class="inp_span" id="show_oldMobile"></span>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-loginPassword">';
	htmlStr += '<label class="control-label">登录密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<span class="inp_span" style="color:#999999;" >登录您的商户后台时需要输入的密码</span>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-payPassword">';
	htmlStr += '<label class="control-label">支付密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<span class="inp_span" style="color:#999999;" >在账户资金变动需要输入的密码</span>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '</form>';
	htmlStr += '</div>';
	htmlStr += '</div>  ';
	htmlStr += '</div>';
	htmlStr += '</div> ';
	htmlStr += '</div> ';
	
	
//	$("#content0").css("display","block");
	showDiv("content0");
	
	$("#content0").html(htmlStr);
	
	getSafeSet();
	getAccount();
	
}


/**
 * 获取安全设置信息
 */
function getSafeSet(){
	
	tips_index=0;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.querysafeSet,"",'$ddf_safeSet.getSafeSetCallBack(data)');
	 eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.querysafeSet,""));
			
			getSafeSetCallBack(data);
			
		}))().start();
}


/**
 * 获取安全设置信息_回调函数
 * @param data
 */
function getSafeSetCallBack(data){
	
	if(data["code"]==1){
		$("#show_shopName").html(data["shopName"]);
		$("#show_oldMobile").html(data["oldMobile"]);
	}else{
		
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
	
}


/**
 * 获取账户信息
 */
function getAccount(){
	
	tips_index=0;

//	DDF_AsyncRequest("POST",ddf.safeSet.querysafeSet,"",'$ddf_safeSet.getSafeSetCallBack(data)');
	 eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.queryAccount,""));
			
			getAccountCallBack(data);
			
		}))().start();
}


/**
 * 获取账户信息_回调函数
 * @param data
 */
function getAccountCallBack(data){
	
	if(data["code"]==1){
		if(data["message"] == '-1'){
			$("#accountUp").css("display","none");
			$("#accountIn").css("display","inline");
		}else{
			$("#accountIn").css("display","none");
			$("#accountUp").css("display","inline");
		}
	}else{
		
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
	
}


function editMobile(){
	history.addHis(this,arguments);//增加历史
	
	var htmlStr="";
	 
	htmlStr += '<div id="content-header">';
	htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href=javascript:$ddf_safeSet.back("content1","content0")>安全设置</a><a href="#" class="current">修改手机</a></div>';
	htmlStr += '</div> ';
	htmlStr += '<div class="container-fluid">';
	htmlStr += '<div class="row-fluid">';
	htmlStr += '<div class="span12">';
	
	htmlStr += '<div id="alert-tips1" ></div>';
	
	
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title">';
	htmlStr += '<span class="icon">';
	htmlStr += '<i class="icon-pencil"></i>';
	htmlStr += '</span>';
	htmlStr += '<h5>操作</h5>';
	htmlStr += '</div>      ';
	htmlStr += '<div class="widget-content">';
	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=$ddf_safeSet.updateMobile() /> ';
	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=$ddf_safeSet.showDiv("content0") />';
	htmlStr += '</div>';
	htmlStr += '</div>             ';
	
    
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
	htmlStr += '<h5>修改手机</h5>';
	htmlStr += '</div>';
	htmlStr += '<div class="widget-content nopadding">';
	htmlStr += '<form class="form-horizontal">	   ';
	htmlStr += '<div class="control-group" id="control-group-oldMobile">';
	htmlStr += '<label class="control-label">旧号码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<span class="inp_span" id="show_old_mobile" ></span>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	

	htmlStr += '<div class="control-group" id="control-group-newMobile">';
	htmlStr += '<label class="control-label">新号码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="text" id="input_Mobile" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '</form>';
	htmlStr += '</div>';
	htmlStr += '</div>  ';
	htmlStr += '</div>';
	htmlStr += '</div> ';
	htmlStr += '</div> ';
	
    showDiv("content1");	
	$("#content1").html(htmlStr);
	
	
	$("#input_Mobile").change(function() {
		
		var inputMobile=$("#input_Mobile").val();
		
		if(isNull(inputMobile)|| !isMobile(inputMobile)){
			addErrorMessage("control-group-newMobile","input_Mobile","新号码非法");
		}else{
			clearErrorMessage("control-group-newMobile");
		}
		
	});
	
	
	tips_index=1;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.showMobile,"",'$ddf_safeSet.editMobileCallBack(data)');
	 eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.showMobile,""));
			
			editMobileCallBack(data);
			
		}))().start();
}

//显示手机号码
function editMobileCallBack(data){
	if(data["code"]==1){
		$("#show_old_mobile").html(data["oldMobile"]);
	}else{
		
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
	
}


/**
 * 重置手机号码
 */
function updateMobile(){
	
	var oldMobile=$("#show_old_mobile").html();
	var newMobile=$("#input_Mobile").val();
	
	if(isNull(oldMobile)||!isMobile(oldMobile)){
		addErrorMessage("control-group-oldMobile","show_old_mobile","旧电话号码非法");
		return;
	}
	
	if(isNull(newMobile)||!isMobile(newMobile)){
		addErrorMessage("control-group-newMobile","input_Mobile","新电话号码非法");
		return;
	}
	
	
	var params={
			"newMobile":newMobile
	        };
	
	tips_index=1;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.resetMobile,params,'$ddf_safeSet.resetMobileCallBack(data)');
	eval(Wind.compile("async",function(){
		
		var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.resetMobile,params));
		
		resetMobileCallBack(data);
		
	}))().start();
	
}

/**
 * 重置手机号码_回调函数
 */
function resetMobileCallBack(data){
	if(data["code"]==1){
		//back("content1","content0");
		showDiv("content0");
		base.tips(data["message"]);
		getSafeSet();
	}else{
		
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
}


/**
 * 修改登录密码
 */
function editLoginPassword(){
	history.addHis(this,arguments);//增加历史
	var htmlStr="";
	 
	htmlStr += '<div id="content-header">';
	htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href=javascript:$ddf_safeSet.show("content0")>安全设置</a><a href="#" class="current">修改登录密码</a></div>';
	htmlStr += '</div> ';
	htmlStr += '<div class="container-fluid">';
	htmlStr += '<div class="row-fluid">';
	htmlStr += '<div class="span12">';
	
	htmlStr += '<div id="alert-tips2" ></div>';
	
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title">';
	htmlStr += '<span class="icon">';
	htmlStr += '<i class="icon-pencil"></i>';
	htmlStr += '</span>';
	htmlStr += '<h5>操作</h5>';
	htmlStr += '</div>      ';
	htmlStr += '<div class="widget-content">';
	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=$ddf_safeSet.updateLoginPassword() /> ';
	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=$ddf_safeSet.showDiv("content0") />';
	htmlStr += '</div>';
	htmlStr += '</div>             ';
	
    
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
	htmlStr += '<h5>修改登录密码</h5>';
	htmlStr += '</div>';
	htmlStr += '<div class="widget-content nopadding">';
	htmlStr += '<form class="form-horizontal">	   ';

	htmlStr += '<div class="control-group" id="control-group-oldLoginPassword">';
	htmlStr += '<label class="control-label">旧密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_oldLoginPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-newLoginPassword">';
	htmlStr += '<label class="control-label">新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_newLoginPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-reNewLoginPassword">';
	htmlStr += '<label class="control-label">确认新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_reNewLoginPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="form-actions">';
//	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=updateLoginPassword() /> ';
//	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=back("content2","content0") />';
	htmlStr += '</div>';
	
	htmlStr += '</form>';
	htmlStr += '</div>';
	htmlStr += '</div>  ';
	htmlStr += '</div>';
	htmlStr += '</div> ';
	htmlStr += '</div> ';
//	alert("denglumima");
//	$("#content0").css("display","none");
//	$("#content2").css("display","block");
	showDiv("content2");
	
	$("#content2").html(htmlStr);
	
	$("#input_oldLoginPassword").change(function() {
		
		var oldLoginPassword=$("#input_oldLoginPassword").val();
		
		if(isNull(oldLoginPassword)){
			addErrorMessage("control-group-oldLoginPassword","input_oldLoginPassword","旧密码不能为空");
		}else if(!isLoginPassword(oldLoginPassword)){
			addErrorMessage("control-group-oldLoginPassword","input_oldLoginPassword","密码为6-20位数字，字母，符号组合，请重新输入！");
		}else{
			clearErrorMessage("control-group-oldLoginPassword");
		}

	});

	$("#input_newLoginPassword").change(function() {

		var newLoginPassword=$("#input_newLoginPassword").val();

		if(isNull(newLoginPassword)){
			addErrorMessage("control-group-newLoginPassword","input_newLoginPassword","新密码不能为空");
		}else if(!isLoginPassword(newLoginPassword)){
			addErrorMessage("control-group-newLoginPassword","input_newLoginPassword","密码为6-20位数字，字母，符号组合，请重新输入！");
		}else{
			clearErrorMessage("control-group-newLoginPassword");
		}

	});

	$("#input_reNewLoginPassword").change(function() {

		var newLoginPassword=$("#input_newLoginPassword").val();
		var reNewLoginPassword=$("#input_reNewLoginPassword").val();

		if(isNull(reNewLoginPassword)){
			addErrorMessage1("control-group-reNewLoginPassword","确认新密码不能为空");
		}else if(!isLoginPassword(reNewLoginPassword)){
			addErrorMessage1("control-group-reNewLoginPassword","密码为6-20位数字，字母，符号组合，请重新输入！");
		}else{
			
			if(newLoginPassword==reNewLoginPassword){
				clearErrorMessage("control-group-reNewLoginPassword");
			}else{
				addErrorMessage1("control-group-reNewLoginPassword","输入的两次新密码不一致");
			}
			
		}

	});
}


/**
 * 重置登录密码
 */
function updateLoginPassword(){
	var oldLoginPassword=$("#input_oldLoginPassword").val();
	var newLoginPassword=$("#input_newLoginPassword").val();
	var reNewLoginPassword=$("#input_reNewLoginPassword").val();
	
	if(isNull(oldLoginPassword)||!isLoginPassword(oldLoginPassword)){
		addErrorMessage("control-group-oldLoginPassword","input_oldLoginPassword","旧密码非法");
		return;
	}else{
		clearErrorMessage("control-group-oldLoginPassword");
	}
	
	if(isNull(newLoginPassword)||!isLoginPassword(newLoginPassword)){
		addErrorMessage("control-group-newLoginPassword","input_newLoginPassword","新密码非法");
		return;
	}else{
		clearErrorMessage("control-group-newLoginPassword");
	}
	
	if(isNull(reNewLoginPassword)||!isLoginPassword(reNewLoginPassword)){
		addErrorMessage1("control-group-reNewLoginPassword","确认新密码非法");
		return;
	}else{
		
		if(newLoginPassword==reNewLoginPassword){
			clearErrorMessage("control-group-reNewLoginPassword");
		}else{
			addErrorMessage1("control-group-reNewLoginPassword","输入的两次新密码不一致");
			return;
		}
		
	}
	
	
	var params={
			"oldLoginPwd":MD5(oldLoginPassword),
			"newLoginPwd":MD5(newLoginPassword)
	        };
	
	tips_index=2;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.resetLoginPwd,params,'$ddf_safeSet.resetLoginPwdCallBack(data)');
     eval(Wind.compile("async",function(){
		
		var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.resetLoginPwd,params));
		
		resetLoginPwdCallBack(data);
		
	}))().start();
}


/**
 * 重置登录密码_回调函数
 * @param data
 */
function resetLoginPwdCallBack(data){
	
	if(data["code"]==1){
//		back("content2","content0");
		showDiv("content0");
		base.tips(data["message"]);
		getSafeSet();
	}else if(data["code"]==2){
		base.tips_error(data["message"]);
	}else{
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
}


/**
 * 修改支付密码
 */
function editPayPassword(){
	history.addHis(this,arguments);//增加历史
	var htmlStr="";
	 
	htmlStr += '<div id="content-header">';
	htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href=javascript:$ddf_safeSet.showDiv("content0")>安全设置</a><a href="#" class="current">修改支付密码</a></div>';
	htmlStr += '</div> ';
	htmlStr += '<div class="container-fluid">';
	htmlStr += '<div class="row-fluid">';
	htmlStr += '<div class="span12">';
	
	htmlStr += '<div id="alert-tips3" ></div>';
	
	
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title">';
	htmlStr += '<span class="icon">';
	htmlStr += '<i class="icon-pencil"></i>';
	htmlStr += '</span>';
	htmlStr += '<h5>操作</h5>';
	htmlStr += '</div>      ';
	htmlStr += '<div class="widget-content">';
	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=$ddf_safeSet.updatePayPassword() /> ';
	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=$ddf_safeSet.showDiv("content0") />';
	htmlStr += '</div>';
	htmlStr += '</div>             ';
	
    
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
	htmlStr += '<h5>修改支付密码</h5>';
	htmlStr += '</div>';
	htmlStr += '<div class="widget-content nopadding">';
	htmlStr += '<form class="form-horizontal">	   ';

	htmlStr += '<div class="control-group" id="control-group-oldPayPassword">';
	htmlStr += '<label class="control-label">旧密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_oldPayPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-newPayPassword">';
	htmlStr += '<label class="control-label">新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_newPayPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-reNewPayPassword">';
	htmlStr += '<label class="control-label">确认新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_reNewPayPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="form-actions">';
//	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=updateLoginPassword() /> ';
//	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=back("content2","content0") />';
	htmlStr += '</div>';
	
	htmlStr += '</form>';
	htmlStr += '</div>';
	htmlStr += '</div>  ';
	htmlStr += '</div>';
	htmlStr += '</div> ';
	htmlStr += '</div> ';
//	
//	$("#content0").css("display","none");
//	$("#content3").css("display","block");
	showDiv("content3");
	$("#content3").html(htmlStr);
	
	$("#input_oldPayPassword").change(function() {
		
		var oldPayPassword=$("#input_oldPayPassword").val();
		
		if(isNull(oldPayPassword)){
			addErrorMessage("control-group-oldPayPassword","input_oldPayPassword","旧密码不能为空");
		}else if(!isPayPassword(oldPayPassword)){
			addErrorMessage("control-group-oldPayPassword","input_oldPayPassword","支付密码为6位数字，请重新输入");
		}else{
			clearErrorMessage("control-group-oldPayPassword");
		}

	});

	$("#input_newPayPassword").change(function() {

		var newPayPassword=$("#input_newPayPassword").val();
		if(isNull(newPayPassword)){
			addErrorMessage("control-group-newPayPassword","input_newPayPassword","新密码非法");
		}else if(!isPayPassword(newPayPassword)){
			addErrorMessage("control-group-newPayPassword","input_newPayPassword","支付密码为6位数字，请重新输入");
		}else{
			clearErrorMessage("control-group-newPayPassword");
		}

	});

	$("#input_reNewPayPassword").change(function() {

		var newPayPassword=$("#input_newPayPassword").val();
		var reNewPayPassword=$("#input_reNewPayPassword").val();

		if(isNull(reNewPayPassword)){
			addErrorMessage1("control-group-reNewPayPassword","确认新密码非法");
		}else if(!isPayPassword(reNewPayPassword)){
			addErrorMessage1("control-group-reNewPayPassword","支付密码为6位数字，请重新输入");
		}else{
			if(newPayPassword==reNewPayPassword){
				clearErrorMessage("control-group-reNewPayPassword");
			}else{
				addErrorMessage1("control-group-reNewPayPassword","输入的两次新密码不一致");
			}
			
		}

	});
}


/**
 * 重置支付密码
 */
function updatePayPassword(){
	var oldPayPassword=$("#input_oldPayPassword").val();
	var newPayPassword=$("#input_newPayPassword").val();
	var reNewPayPassword=$("#input_reNewPayPassword").val();
	
	
	if(isNull(oldPayPassword)||!isPayPassword(oldPayPassword)){
		addErrorMessage("control-group-oldPayPassword","input_oldPayPassword","旧密码非法");
		return;
	}else{
		clearErrorMessage("control-group-oldPayPassword");
	}
	
	if(isNull(newPayPassword)||!isPayPassword(newPayPassword)){
		addErrorMessage("control-group-newPayPassword","input_newPayPassword","新密码非法");
		return;
	}else{
		clearErrorMessage("control-group-newPayPassword");
	}
	
	if(isNull(reNewPayPassword)||!isPayPassword(reNewPayPassword)){
		addErrorMessage1("control-group-reNewPayPassword","确认新密码非法");
		return;
	}else{
		
		if(newPayPassword==reNewPayPassword){
			clearErrorMessage("control-group-reNewPayPassword");
		}else{
			addErrorMessage1("control-group-reNewPayPassword","输入的两次新密码不一致");
			return;
		}
		
	}
	
	
	var params={
			"oldPayPwd":MD5(oldPayPassword),
			"newPayPwd":MD5(newPayPassword)
	        };
	
	tips_index=3;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.resetPayPwd,params,'$ddf_safeSet.resetPayPwdCallBack(data)');
	 eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.resetPayPwd,params));
			
			resetPayPwdCallBack(data);
			
		}))().start();
}


/**
 * 重置支付密码_回调函数
 * @param data
 */
function resetPayPwdCallBack(data){
	if(data["code"]==1){
		showDiv("content0");
		base.tips(data["message"]);
		getSafeSet();
	}else if(data["code"]==2){
		base.tips_error(data["message"]);
	}else{
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
}



/**
 * 新增支付密码
 */
function loadinsertPayPassword(){
	history.addHis(this,arguments);//增加历史
	var htmlStr="";
	 
	htmlStr += '<div id="content-header">';
	htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href=javascript:$ddf_safeSet.showDiv("content0")>安全设置</a><a href="#" class="current">新增支付密码</a></div>';
	htmlStr += '</div> ';
	htmlStr += '<div class="container-fluid">';
	htmlStr += '<div class="row-fluid">';
	htmlStr += '<div class="span12">';
	
	htmlStr += '<div id="alert-tips3" ></div>';
	
	
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title">';
	htmlStr += '<span class="icon">';
	htmlStr += '<i class="icon-pencil"></i>';
	htmlStr += '</span>';
	htmlStr += '<h5>操作</h5>';
	htmlStr += '</div>      ';
	htmlStr += '<div class="widget-content">';
	htmlStr += '<input type="button" value="确认新增" class="btn btn-primary" onClick=$ddf_safeSet.insertPayPassword() /> ';
	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=$ddf_safeSet.showDiv("content0") />';
	htmlStr += '</div>';
	htmlStr += '</div>             ';
	
    
	htmlStr += '<div class="widget-box">';
	htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
	htmlStr += '<h5>新增支付密码</h5>';
	htmlStr += '</div>';
	htmlStr += '<div class="widget-content nopadding">';
	htmlStr += '<form class="form-horizontal">	   ';

	htmlStr += '<div class="control-group" id="control-group-newPayPassword">';
	htmlStr += '<label class="control-label">新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_newPayPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="control-group" id="control-group-reNewPayPassword">';
	htmlStr += '<label class="control-label">确认新密码：</label>';
	htmlStr += '<div class="controls">';
	htmlStr += '<input class="span2" type="password" id="input_reNewPayPassword" value=""/>';
	htmlStr += '</div>              ';
	htmlStr += '</div>';
	
	htmlStr += '<div class="form-actions">';
//	htmlStr += '<input type="button" value="确认修改" class="btn btn-primary" onClick=updateLoginPassword() /> ';
//	htmlStr += '<input type="button" value="返回" class="btn btn-info" onClick=back("content2","content0") />';
	htmlStr += '</div>';
	
	htmlStr += '</form>';
	htmlStr += '</div>';
	htmlStr += '</div>  ';
	htmlStr += '</div>';
	htmlStr += '</div> ';
	htmlStr += '</div> ';
//	
//	$("#content0").css("display","none");
//	$("#content3").css("display","block");
	showDiv("content3");
	$("#content3").html(htmlStr);
	
	$("#input_newPayPassword").change(function() {

		var newPayPassword=$("#input_newPayPassword").val();
		if(isNull(newPayPassword)){
			addErrorMessage("control-group-newPayPassword","input_newPayPassword","新密码非法");
		}else if(!isPayPassword(newPayPassword)){
			addErrorMessage("control-group-newPayPassword","input_newPayPassword","支付密码为6位数字，请重新输入");
		}else{
			clearErrorMessage("control-group-newPayPassword");
		}

	});

	$("#input_reNewPayPassword").change(function() {

		var newPayPassword=$("#input_newPayPassword").val();
		var reNewPayPassword=$("#input_reNewPayPassword").val();

		if(isNull(reNewPayPassword)){
			addErrorMessage("control-group-reNewPayPassword","input_reNewPayPassword","确认新密码非法");
		}else if(!isPayPassword(reNewPayPassword)){
			addErrorMessage("control-group-reNewPayPassword","input_reNewPayPassword","支付密码为6位数字，请重新输入");
		}else{
			if(newPayPassword==reNewPayPassword){
				clearErrorMessage("control-group-reNewPayPassword");
			}else{
				addErrorMessage("control-group-reNewPayPassword","input_reNewPayPassword","输入的两次新密码不一致");
			}
			
		}

	});
}


/**
 * 新增支付密码
 */
function insertPayPassword(){
	var newPayPassword=$("#input_newPayPassword").val();
	var reNewPayPassword=$("#input_reNewPayPassword").val();
	
	if(isNull(newPayPassword)||!isPayPassword(newPayPassword)){
		addErrorMessage("control-group-newPayPassword","input_newPayPassword","新密码非法");
		return;
	}else{
		clearErrorMessage("control-group-newPayPassword");
	}
	
	if(isNull(reNewPayPassword)||!isPayPassword(reNewPayPassword)){
		addErrorMessage("control-group-reNewPayPassword","input_reNewPayPassword","确认新密码非法");
		return;
	}else{
		
		if(newPayPassword==reNewPayPassword){
			clearErrorMessage("control-group-reNewPayPassword");
		}else{
			addErrorMessage("control-group-reNewPayPassword","input_reNewPayPassword","输入的两次新密码不一致");
			return;
		}
		
	}
	
	
	var params={
			"tsAccount.password":MD5(newPayPassword)
	        };
	
	tips_index=3;

	base.showLoading();
	
//	DDF_AsyncRequest("POST",ddf.safeSet.resetPayPwd,params,'$ddf_safeSet.resetPayPwdCallBack(data)');
	 eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.safeSet.addUserAccount,params));
			
			insertPayPwdCallBack(data);
			
		}))().start();
}


/**
 * 新增支付密码_回调函数
 * @param data
 */
function insertPayPwdCallBack(data){
	if(data["code"]==1){
		showDiv("content0");
		base.tips(data["message"]);
		getSafeSet();
		getAccount();
	}else if(data["code"]==2){
		base.tips_error(data["message"]);
	}else{
		 base.tips_error(data["message"]);
	}
	base.cancelLoading();
}




function showDiv(block){
	
	$("#content > div").hide();
	
	if($("#"+block).length<=0){
		
		$("#content").append('<div id="'+block+'"></div>'); 
		
	}else{
		
		$("#"+block).show();
	}
}
//暴露方法
exports.getSafeSet=getSafeSet;
exports.getSafeSetCallBack=getSafeSetCallBack;
exports.getAccount=getAccount;
exports.getAccountCallBack=getAccountCallBack;
exports.editMobile=editMobile;
exports.editMobileCallBack=editMobileCallBack;
exports.updateMobile=updateMobile;
exports.resetMobileCallBack=resetMobileCallBack;
exports.editLoginPassword=editLoginPassword;
exports.updateLoginPassword=updateLoginPassword;
exports.resetLoginPwdCallBack=resetLoginPwdCallBack;
exports.editPayPassword=editPayPassword;
exports.updatePayPassword=updatePayPassword;
exports.resetPayPwdCallBack=resetPayPwdCallBack;
exports.loadinsertPayPassword=loadinsertPayPassword;
exports.insertPayPassword=insertPayPassword;
exports.insertPayPwdCallBack=insertPayPwdCallBack;
exports.showDiv = showDiv;

});